unit MainUnit;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Grids, SumUnit, Spin;

type
  TForm1 = class(TForm)
    StringGrid1: TStringGrid;
    Label1: TLabel;
    SpinEdit1: TSpinEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  m:array of integer;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  begin
Label1.caption:=inttostr(sum(m));
  end;




procedure TForm1.SpinEdit1Change(Sender: TObject);
var i:integer;
     begin
Randomize;
  StringGrid1.ColCount :=  SpinEdit1.Value;
  SetLength(m,SpinEdit1.Value);
  for i:=0 to SpinEdit1.Value - 1 do
     begin
       m[i]:=random(200)-100;
       StringGrid1.Cells[i,0]:=inttostr(m[i]);
  end;

     end;
end.
